// calendar-utils.js
export function generateCalendar(date = new Date()) {
  const weeks = [];
  const year = date.getFullYear();
  const month = date.getMonth();
  
  // 当月第一天
  const firstDay = new Date(year, month, 1);
  // 当月最后一天
  const lastDay = new Date(year, month + 1, 0);
  
  // 日历开始日期（前个月最后几天）
  const startDay = new Date(firstDay);
  startDay.setDate(startDay.getDate() - startDay.getDay());
  
  // 日历结束日期（下个月前几天）
  const endDay = new Date(lastDay);
  endDay.setDate(endDay.getDate() + (6 - endDay.getDay()));
  
  const current = new Date(startDay);
  while (current <= endDay) {
    weeks.push(new Date(current));
    current.setDate(current.getDate() + 1);
  }
  
  return weeks;
}